A device isolation region is formed in order to electrically separate devices formed on a semiconductor substrate. An example of the device isolation region is a shallow trench isolation (STI) structure in which a trench formed in a semiconductor substrate is filled with an insulating film. In a case wires are patterned on the STI structure, an etching residue may be generated in an end portion of the STI structure, which causes, for example, a short circuit between the wires.